package com.orange.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.orange.domain.Notice;
import com.orange.dto.NoticeDto;
import com.orange.mapper.NoticeMapper;
import com.orange.service.NoticeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return noticeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Notice record) {
        return noticeMapper.insert(record);
    }

    @Override
    public int insertSelective(Notice record) {
        return noticeMapper.insertSelective(record);
    }

    @Override
    public Notice selectByPrimaryKey(Integer id) {
        return noticeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Notice record) {
        return noticeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Notice record) {
        return noticeMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<Notice> queryByPage(NoticeDto noticeDto) {
        Page<Notice> page = PageHelper.startPage(noticeDto.getPage(), noticeDto.getLimit());
        List<Notice> list = noticeMapper.queryAll(noticeDto);
        return page.toPageInfo();
    }

    @Override
    public List<Notice> queryAll() {
        return noticeMapper.queryAll(new NoticeDto());
    }

}
